import {HTTP} from "../../utils/http";

const BASE_URL = "HomePage/"
const GET_SUBJECT_PAGE = BASE_URL+ "get_course_list"
const GET_SUBJECT_DETAIL = BASE_URL + "get_course_details"
const GET_SUBJECT_BY_CA = BASE_URL + "get_course_list_ca"

class SubjectModel extends HTTP{

    constructor(){
        super()
    }


    /**
     * 获取课程分页
     * @param type
     * @param current
     * @param pageSize
     * @returns {*|Promise|Promise<any>}
     */
    getSubjectPage(type,current,pageSize){

        return this.request({
            url: GET_SUBJECT_PAGE,
            data:{
                type: type,
                page: current,
                pagesize: pageSize
            }
        })

    }

    /**
     * 根据分类获取课程
     * @param caId
     * @param current
     * @param pageSize
     * @returns {*|Promise|Promise<any>}
     */
    getSubjectByCa(caId,current,pageSize){

        return this.request({
            url: GET_SUBJECT_BY_CA,
            data:{
                ca_id: caId,
                page: current,
                pagesize: pageSize
            }
        })

    }



    /**
     * 获取课程详情
     * @param cId
     * @param userId 传入以判断是否收藏
     */
    getSubjectDetail(cId,userId){

        return this.request({
            url: GET_SUBJECT_DETAIL,
            data: {
                "c_id": cId,
                "user_id": userId
            }
        })
    }

}
export {SubjectModel}